//1. 导入 mongoose
const mongoose = require('mongoose');
const moment = require('moment');

//2. 创建结构对象
const UserSchema = new mongoose.Schema({
  uname: {
    type: String,
    required: true
  },
  pwd: {
    type: String,
    required: true
  },
  profile: {
    type: String,
    default: 'https://joeschmoe.io/api/v1/random'
  },
  create_at: {
    type: String,
    default: moment().format('YYYY-MM-DD HH:mm:ss')
  },
  last_login: {
    type: String,
    default: moment().format('YYYY-MM-DD HH:mm:ss')
  }
});

//3. 创建模型对象
const UserModel = new mongoose.model('user', UserSchema);

//4. 暴露对象
module.exports = UserModel;